import React from "react"
import {messages} from "share/common";
import {
  Button,
  Form,
  Switch,
  Input,
  message,
  InputNumber,
  Spin,
  Select,
  Card,
  DatePicker,
  TimePicker,
  Modal,
  Radio
} from 'antd';
import moment from 'moment';
import constants from 'share/constants'
import Chooser from "components/chooser";
import bookingManagerService from 'containers/booking-management/booking-manager.service'
import 'styles/booking-management/booking-details.scss'

const RadioGroup = Radio.Group;

const FormItem = Form.Item;
const Option = Select.Option;

class BookingDetailsMaintain extends React.Component {
  constructor() {
    super();
    this.state = {
      loading: false,
      value: 1,
      isNew: true,
      isRefund: false,
      isRefunding: false,
      isCopy: false,
      readonly: false,
      bunkList: [
        {name: messages('booking-management.key17'/*经济舱*/)},
        {name: messages('booking-management.key18'/*超级经济舱*/)},
        {name: messages('booking-management.key19'/*商务舱*/)},
        {name: messages('booking-management.key20'/*头等舱*/)}
      ],
      refundAndNoticeVisible: false,
      refundVisible: false,
      priceAuditor: null,
      params: {},
      currencyCode: null,
      passengerName: [],
      currentPassenger: "",
      isShowRefundBtn: false,// 是否显示退票按钮(内部员工)
      isOldFunc: false, // 是否是老功能，（后面会完全采用新的）
    }
  }

  //只要有props的值发生变化，就会调用该方法
  componentWillReceiveProps(nextProps) {
    if (!nextProps.params || nextProps.params === this.props.params) {
      return false;
    } else {
      let passengerName = [];
      const {params} = nextProps;
      if (params) {
        const {travelOrder} = params;
        if (travelOrder.type === 1001 && !params.isNew) {
          passengerName.push({
            label: travelOrder.name,
            key: travelOrder.userOID,
            fullName: travelOrder.name,
            userOID: travelOrder.userOID
          });
        }
        this.setState({
          isOldFunc: params.isOldFunc,
          isNew: params.isNew,
          isRefund: params.isRefund,
          priceAuditor: params.priceAuditor,
          isCopy: params.isCopy,
          readonly: params.readonly,
          params: params.travelOrder,
          currencyCode: params.currencyCode,
          passengerName: passengerName,
          currentPassenger: travelOrder.name,
          isShowRefundBtn: ((travelOrder.status === 1003 ||
            travelOrder.status === 1005 ||
            travelOrder.status === 1006) &&
            !params.isRefund && !params.isNew && !params.isCopy)
        });
      }
    }

  }

  //取消按钮
  onCancel = () => {
    this.props.form.resetFields();
    this.setState({
      params: {},
      isNew: true,
      isRefund: false,
      isCopy: false,
      readonly: false
    });
    this.props.close();
  };

  handleCancel = (type) => {
    if (type === "REFUNDANDNOTICE") {
      this.setState({refundAndNoticeVisible: false});
    }
    if (type === "NOTICE") {
      this.setState({refundVisible: false});
    }
  };

  //获取已选乘机人
  getPassenger = (result) => {
    const {isNew, params} = this.state;
    const {form} = this.props;
    let currentPassenger = "";
    if (result && result.length) {
      currentPassenger = result[0].fullName;
    }
    this.setState({
      passengerName: result,
      currentPassenger: currentPassenger
    });

    if (result && result.length) {
      form.setFieldsValue({'name': result[0].fullName});
      form.setFieldsValue({'userOID': result[0].userOID});
      // 如果chooser onchange拿到的人和传进来的值一样，cardNO还是用传进来的值，这里是为了应对后端数据不全，
      // 创建订单时填了cardNO但通过以下方法在数据库里查不到
      if (!isNew && ((result[0].key === params.userOID) && params.cardNo)) {
        form.setFieldsValue({'cardNo': params.cardNo});
        form.setFieldsValue({'cardType': params.cardType});
      } else {
        this.setState({loading: true});
        bookingManagerService.getDefaultCards(result[0].userOID).then((response) => {
          form.setFieldsValue({'cardNo': response.data.originalCardNo});
          form.setFieldsValue({'cardType': response.data.cardTypeName});
          this.setState({loading: false});
        }).catch(e => {
          this.setState({loading: false});
          message.error(e.response.data.message);
        });
      }
    } else {
      form.setFieldsValue({'cardNo': ""});  //清空chooser
    }
  };
  //仅保存
  updateOrder = (e, noticeUser) => {
    e.preventDefault();
    this.props.form.validateFieldsAndScroll((err, values) => {
      if (!err) { //表单验证通过
        let newOrder = {};
        const {params} = this.state;
        newOrder = Object.assign(newOrder, params, values);
        newOrder.finalPrice = Number(newOrder.finalPrice.replace(',',''));
        if(params.status === 1003){// 已改签
          newOrder.price = Math.abs(Number(newOrder.price || 0) + Number(newOrder.endorsePrice || 0));
        }
        newOrder.endorsePrice = Math.abs(Number(newOrder.endorsePrice || 0));
        newOrder.taxationPrice = Math.abs(Number(newOrder.taxationPrice || 0));
        if (this.state.isCopy) { //如果是编辑并复制 则 保存为一条新的记录
          newOrder.travelOrderOID = null;
        }
        let paramsOptions = {
          travelBookerApplicationId: params.travelBookerApplicationId,
          oldFunction: this.props.params.isOldFunc,
        }
        // 航班日期为 年月日加起飞时间的时分秒组合成UTC时间
        let beginTime = moment(newOrder.beginDate).local().format('HH:mm');
        let traveDate = moment(newOrder.travelDate).local().format('YYYY-MM-DD');
        newOrder.travelDate = `${moment(traveDate + ' ' + beginTime).utc().format()}`;
        this.handleCancel("NOTICE");
        this.setState({loading: true});
        bookingManagerService.updateOrder(noticeUser, newOrder, paramsOptions).then(() => {
          this.props.form.resetFields();
          this.props.close(true);
          this.setState({loading: false});
          message.success(messages('common.save.success', {name: messages('booking-management.key21')}));
        }).catch(e => {
          this.setState({loading: false});
          message.error(e.response.data.message);
        });
      } else {
        return false;
      }
    });

  };

  notification = (e) => {
    const {params, isRefund} = this.state;
    if (params.type === 1002) {
      if (isRefund) {
        this.refundTravelOrder();
      } else {
        this.updateOrder(e, true);
      }
    } else {
      //内部员工
      if (isRefund) {
        this.props.form.validateFieldsAndScroll((err, values) => {
          if (!err) { //表单验证通过
            this.setState({refundAndNoticeVisible: true});
          }
        });
      } else {
        this.props.form.validateFieldsAndScroll((err, values) => {
          if (!err) { //表单验证通过
            this.setState({refundVisible: true});
          }
        });
      }
    }
  };

  refundTravelOrder = () => {
    const {params, isRefunding} = this.state;
    const data = {};
    this.props.form.validateFieldsAndScroll((err, values) => {
      if (!err) { //表单验证通过
        Object.assign(data, params, values);
        data.finalPrice = Number(data.finalPrice.replace(',',''));
        if(params.status === 1003){// 已改签
          data.price = Math.abs(Number(data.price) + Number(data.endorsePrice || 0));
        }
        data.endorsePrice = Math.abs(Number(data.endorsePrice || 0));
        data.taxationPrice = Math.abs(Number(data.taxationPrice || 0));
        if (isRefunding) {
          data.status = 1002;
        }
        if (this.state.isCopy) { //如果是编辑并复制 则 保存为一条新的记录
          data.travelOrderOID = null;
        }
        let paramsOptions = {
          travelBookerApplicationId: params.travelBookerApplicationId,
          oldFunction: this.props.params.isOldFunc,
        }
        this.setState({loading: true});
        this.handleCancel("REFUNDANDNOTICE");
        bookingManagerService.refundTravelOrder(data, paramsOptions).then(() => {
          this.props.form.resetFields();
          this.props.close(true);
          this.setState({loading: false});
          message.success(messages('common.operate.success'));
        }).catch(e => {
          this.setState({loading: false});
          message.error(e.response.data.message);
        });
      } else {
        return false;
      }
    });

  };

  // 计算最终金额
  calcFinalPrice = (e, value) => {
    const { form } = this.props;
    if(typeof e !== 'number'){
      return;
    }
    setTimeout(() => {
      let price = form.getFieldValue('price') || 0;                    // 机票价格
      let taxationPrice = form.getFieldValue('taxationPrice') || 0;    // 税费
      let insurancePrice = form.getFieldValue('insurancePrice') || 0;  // 保险费
      let servicePrice = form.getFieldValue('servicePrice') || 0;      // 服务费
      let sendTicketsPrice = form.getFieldValue('sendTicketsPrice') || 0;// 送票费
      let endorsePrice = form.getFieldValue('endorsePrice') || 0;        // 改签费
      let refundPrice = form.getFieldValue('refundPrice') || 0;          // 退票手续费
      let finalPrice = price + taxationPrice + insurancePrice + servicePrice + sendTicketsPrice + endorsePrice + refundPrice;
      this.props.form.setFieldsValue({'finalPrice': this.filterMoney(finalPrice, 2, true)});
    },10)
    return e;
  };

  refund = () => {
    const { form } = this.props;
    let price = form.getFieldValue('price') || 0;                    // 机票价格
    let taxationPrice = form.getFieldValue('taxationPrice') || 0;    // 税费
    let endorsePrice = form.getFieldValue('endorsePrice') || 0;    // 改签费
    form.setFieldsValue({'price': -Math.abs(price)});
    form.setFieldsValue({'taxationPrice': -Math.abs(taxationPrice)});
    form.setFieldsValue({'endorsePrice': -Math.abs(endorsePrice)});
    this.calcFinalPrice(0);
    this.setState({isRefund: true, isRefunding: true, isShowRefundBtn: false});
  };

  render() {
    const {loading, isNew, isRefund, isCopy, readonly, params, bunkList, priceAuditor, refundAndNoticeVisible} = this.state;
    const { refundVisible, currencyCode, passengerName, currentPassenger, isShowRefundBtn, isOldFunc} = this.state;
    const {getFieldDecorator} = this.props.form;
    const {TextArea} = Input;
    const formItemLayout = {
      labelCol: {span: 6, offset: 1},
      wrapperCol: {span: 14, offset: 1},
    };
    const format = 'HH:mm';
    const dateFormat = 'YYYY-MM-DD';
    let confirmRemark = "";
    let renderTravelDetail = "";
    if (params.travelOrderOID && !(isNew || isCopy)) {
      if (params.confirmStatus === 1003 && params.confirmRemark) {
        confirmRemark = `：${params.confirmRemark}`;
      }
      renderTravelDetail = `${ moment(params.lastModifiedDate).format('YYYY-MM-DD HH:mm:ss')} ${constants.getTextByValue(params.status, 'ticketStatus')}${params.confirmStatus !== 1000 ? "," : ""}${constants.getTextByValue(params.confirmStatus, 'ticketConfirmStatus')}${confirmRemark}`;
    }
    let outDisabledAndTip = (priceAuditor && params.status !== 1009) ||
      (priceAuditor && params.status === 1009 && isCopy) ||
      (!priceAuditor && !isCopy && params.status === 1005) ||
      (isRefund && params.refundPrice === null) ||
      params.status === 1000 ||
      params.status === 1002 ||
      params.status === 1003 ||
      params.status === 1004;

    let isDisOnlySave = (isRefund && params.refundPrice === null) ||
      (params.status === 1005 && !isCopy) ||
      params.status === 1000 ||
      params.status === 1002 ||
      params.status === 1003 ||
      params.status === 1004;

    let outDis = priceAuditor &&
      params.status !== 1009 ||
      (priceAuditor && params.status === 1009 && isCopy) ||
      (isRefund && params.refundPrice === null);

    const issueAndNoticeBtn = (
      <Button
        type="primary"
        loading={loading}
        disabled={outDisabledAndTip}
        onClick={(e) => this.notification(e)}
      >
        {messages('booking-management.key22'/*出票并通知乘机人*/)}
      </Button>
    );

    const issueBtn = (
      <Button
        type="primary"
        loading={loading}
        disabled={outDis}
        onClick={(e) => this.notification(e)}
      >
        {messages('booking-management.key23'/*出票*/)}
      </Button>
    );

    const refundAndNoticeBtn = (
      <Button
        type="primary"
        loading={loading}
        disabled={params.status === 1002}
        onClick={(e) => this.notification(e)}
      >
        {messages('booking-management.key24'/*退票并通知乘机人*/)}
      </Button>
    );

    const refundBtn = (
      <Button
        type="danger"
        loading={loading}
        disabled={params.status === 1002}
        onClick={(e) => this.notification(e)}
      >
        {messages('booking-management.key25'/*退票*/)}
      </Button>
    );

    const refundBtnAffix = (
      <Button
        type="danger"
        loading={loading}
        onClick={() => this.refund()}
      >
        {messages('booking-management.key25'/*退票*/)}
      </Button>
    );

    const refundInput = (
      <FormItem
        {...formItemLayout}
        label={messages('booking-management.key100', {arg1: currencyCode}/*退票手续费（{arg1}）*/)}
      >
        {getFieldDecorator('refundPrice', {
          initialValue: isRefund && params.refundPrice !== null ? Number(params.refundPrice) : Number(0),
          getValueFromEvent: (e) => this.calcFinalPrice(e, "refundPrice")
        })(
          <InputNumber step="0.01" placeholder={messages('common.please.enter')}/>
        )}
      </FormItem>
    );

    const nameChooser = (
      <FormItem {...formItemLayout} label={messages('booking-management.key26'/*姓名*/)}>
        {getFieldDecorator('name', {
          rules: [{
            required: true,
            message: messages('booking-management.key27'/*请输入乘机人姓名*/)
          }],
          initialValue: isNew ? '' : params.name
        })(
          <Input type="hidden"/>
        )}
        <Chooser
          type={"passenger"}
          disabled={readonly}
          single={true}
          labelKey={"fullName"}
          valueKey={"userOID"}
          listExtraParams={params.applicationParticipants}
          value={passengerName}
          onChange={this.getPassenger}
        />
      </FormItem>
    );

    const nameInput = (
      <FormItem {...formItemLayout} label={messages('booking-management.key26'/*姓名*/)}>
        {getFieldDecorator('name', {
          rules: [{
            required: true,
            message: messages('booking-management.key27'/*请输入乘机人姓名*/)
          }],
          initialValue: isNew ? '' : params.name
        })(
          <Input disabled={readonly} placeholder={messages('common.please.enter')}/>
        )}
      </FormItem>
    );

    return (
      <div className="booking-details-maintain">
        <Form>
          <Card
            bordered={false}
            style={(isNew || isCopy) ? {display: "none"} : {wordBreak: "break-all"}}
          >
            {renderTravelDetail}
          </Card>
          {/*乘机人*/}
          <Card title={messages('booking-management.key28'/*乘机人*/)} bordered={false}>
            {params.type === 1001 ? nameChooser : "" /*这里travelOrder的type不是bookerType了是乘机人类型 1001内部乘机人，1002外部乘机人*/}
            {params.type === 1002 ? nameInput : ""}
            <Spin spinning={loading}>
              <FormItem {...formItemLayout} label={messages('booking-management.key111')/*证件类型*/}>
                {getFieldDecorator('cardType', {
                  rules: [{
                    required: true,
                    message: messages('booking-management.key112')/*请输入证件类型*/
                  }],
                  initialValue: isNew ? '' : params.cardType
                })(
                  <Input
                    disabled={readonly}
                    placeholder={(!isNew || (isNew && params.type === 1001)) ? "" : messages('common.please.enter')}
                  />
                )}
              </FormItem>
              <FormItem {...formItemLayout} label={messages('booking-management.key29'/*证件号*/)}>
                {getFieldDecorator('cardNo', {
                  rules: [{
                    required: true,
                    message: messages('booking-management.key30'/*请输入乘机人证件号*/)
                  }],
                  initialValue: isNew ? '' : params.cardNo
                })(
                  <Input
                    disabled={readonly}
                    placeholder={(!isNew || (isNew && params.type === 1001)) ? "" : messages('common.please.enter')}
                  />
                )}
              </FormItem>
              <FormItem {...formItemLayout} className={"hide"}>
                {getFieldDecorator('userOID', {
                  initialValue: isNew ? '' : params.userOID
                })(
                  <Input type="hidden"/>
                )}
              </FormItem>
            </Spin>
          </Card>
          {/*机票信息*/}
          <Card title={messages('booking-management.key31'/*机票信息*/)} bordered={false}>
            <FormItem {...formItemLayout} label={messages('booking-management.key113')/*行程类型*/}>
              {getFieldDecorator('itineraryType', {
                rules: [{
                  required: true,
                  message: messages('common.select')/*请选择*/
                }],
                initialValue: isNew ? 1001 : params.itineraryType
              })(
                <RadioGroup>
                  <Radio value={1001}>{messages('request.key374'/*单程*/)}</Radio>
                  <Radio value={1003}>{messages('booking-management.key114')/*去程*/}</Radio>
                  <Radio value={1004}>{messages('booking-management.key115')/*返程*/}</Radio>
                </RadioGroup>
              )}
            </FormItem>
            <FormItem {...formItemLayout} label={messages('booking-management.key32'/*航班日期*/)}>
              {getFieldDecorator('travelDate', {
                rules: [{
                  required: true,
                  message: messages('booking-management.key33'/*请输入航班日期*/)
                }],
                initialValue: isNew ? moment(new Date(), dateFormat) : moment(new Date(params.travelDate), dateFormat)
              })(
                <DatePicker/>
              )}
            </FormItem>
            <FormItem {...formItemLayout} label={messages('booking-management.key34'/*起飞时间*/)}>
              {getFieldDecorator('beginDate', {
                rules: [{
                  required: true,
                  message: messages('booking-management.key35'/*请输入起飞时间*/)
                }],
                initialValue: isNew ? moment('00:00', format) : moment(new Date(params.beginDate), "HH:mm:ss")
              })(
                <TimePicker format={format}/>
              )}
            </FormItem>
            <FormItem {...formItemLayout} label={messages('booking-management.key36'/*到达时间*/)}>
              {getFieldDecorator('arriveDate', {
                rules: [{
                  required: true,
                  message: messages('booking-management.key37'/*请输入到达时间*/)
                }],
                initialValue: isNew ? moment('00:00', format) : moment(new Date(params.arriveDate), "HH:mm:ss")
              })(
                <TimePicker format={format}/>
              )}
            </FormItem>
            <FormItem {...formItemLayout} label={messages('booking-management.key38'/*航班号*/)}>
              {getFieldDecorator('travelNo', {
                rules: [{
                  required: true,
                  message: messages('booking-management.key39'/*请输入航班号*/)
                }],
                initialValue: isNew ? '' : params.travelNo
              })(
                <Input placeholder={messages('common.please.enter')}/>
              )}
            </FormItem>
            <FormItem {...formItemLayout} label={messages('booking-management.key40'/*出发机场*/)}>
              {getFieldDecorator('fromAirport', {
                rules: [{
                  required: true,
                  message: messages('booking-management.key41'/*请输入出发机场*/)
                }],
                initialValue: isNew ? '' : params.fromAirport
              })(
                <Input placeholder={messages('common.please.enter')}/>
              )}
            </FormItem>
            <FormItem {...formItemLayout} label={messages('booking-management.key42'/*到达机场*/)}>
              {getFieldDecorator('toAirport', {
                rules: [{
                  required: true,
                  message: messages('booking-management.key43'/*请输入到达机场*/)
                }],
                initialValue: isNew ? '' : params.toAirport
              })(
                <Input placeholder={messages('common.please.enter')}/>
              )}
            </FormItem>
            <FormItem {...formItemLayout} label={messages('booking-management.key44'/*舱位*/)}>
              {getFieldDecorator('bunk', {
                rules: [{
                  required: true,
                  message: messages('booking-management.key45'/*请输入舱位*/)
                }],
                initialValue: isNew ? messages('booking-management.key17'/*经济舱*/) : params.bunk
              })(
                <Select
                  placeholder={messages('common.please.select')/*请选择*/}
                  onFocus={this.clickBalanceDirectionSelect}
                >
                  {bunkList.map(option => {
                    return <Option key={option.name} value={option.name}>{option.name}</Option>
                  })}
                </Select>
              )}
            </FormItem>
            <FormItem {...formItemLayout} label={messages('booking-management.key46'/*供应商*/)}>
              {getFieldDecorator('supplyName', {
                rules: [{
                  message: messages('common.please.enter')
                }],
                initialValue: isNew ? '' : params.supplyName
              })(
                <Input placeholder={messages('common.please.enter')}/>
              )}
            </FormItem>
            <FormItem {...formItemLayout} label={messages('booking-management.key47'/*供应商电话*/)}>
              {getFieldDecorator('supplyTel', {
                rules: [{
                  message: messages('common.please.enter')
                }],
                initialValue: isNew ? '' : params.supplyTel
              })(
                <Input type="tel" placeholder={messages('common.please.enter')}/>
              )}
            </FormItem>
          </Card>
          {/*费用*/}
          <Card title={messages('booking-management.key48'/*费用*/)} bordered={false}>
            <FormItem
              {...formItemLayout}
              label={messages('booking-management.key101', {currencyCode: currencyCode}/*机票价格*/)}
            >
              {getFieldDecorator('price', {
                rules: [{
                  required: true,
                  message: messages('booking-management.key49'/*请输入机票价格*/)
                }],
                initialValue: isNew ? '' : Number(params.price) - Number(params.endorsePrice),
                getValueFromEvent: (e) => this.calcFinalPrice(e, "price")
              })(
                <InputNumber
                  step="0.01"
                  placeholder={messages('common.please.enter')}
                  disabled={(isShowRefundBtn || params.status === 1007 || isRefund)}
                />
              )}
            </FormItem>
            <FormItem {...formItemLayout} label={messages('booking-management.key102', {currencyCode: currencyCode}/*税费*/)}>
              {getFieldDecorator('taxationPrice', {
                rules: [{
                  required: true,
                  message: messages('booking-management.key50'/*请输入税费*/)
                }],
                initialValue: isNew ? '' : Number(params.taxationPrice),
                getValueFromEvent: (e) => this.calcFinalPrice(e, "taxationPrice")
              })(
                <InputNumber
                  step="0.01"
                  placeholder={messages('common.please.enter')}
                  disabled={(isShowRefundBtn || params.status === 1007 || isRefund)}
                />
              )}
            </FormItem>
            <FormItem {...formItemLayout} label={messages('booking-management.key103', {currencyCode: currencyCode}/*保险费*/)}>
              {getFieldDecorator('insurancePrice', {
                initialValue: isNew ? '' : Number(params.insurancePrice),
                getValueFromEvent: (e) => this.calcFinalPrice(e, "insurancePrice")
              })(
                <InputNumber
                  step="0.01"
                  placeholder={messages('common.please.enter')}
                  disabled={params.status === 1007}
                />
              )}
            </FormItem>
            <FormItem {...formItemLayout} label={messages('booking-management.key104', {arg1: currencyCode}/*服务费（{arg1}）*/)}>
              {getFieldDecorator('servicePrice', {
                initialValue: isNew ? '' : Number(params.servicePrice),
                getValueFromEvent: (e) => this.calcFinalPrice(e, "servicePrice")
              })(
                <InputNumber
                  step="0.01"
                  placeholder={messages('common.please.enter')}
                  disabled={params.status === 1007}
                />
              )}
            </FormItem>
            <FormItem {...formItemLayout} label={messages('booking-management.key105', {arg1: currencyCode}/*送票费（{arg1}）*/)}>
              {getFieldDecorator('sendTicketsPrice', {
                initialValue: isNew ? '' : Number(params.sendTicketsPrice),
                getValueFromEvent: (e) => this.calcFinalPrice(e, "sendTicketsPrice")
              })(
                <InputNumber
                  step="0.01"
                  placeholder={messages('common.please.enter')}
                  disabled={params.status === 1007}
                />
              )}
            </FormItem>
            {
              (params.status === 1003 || params.status === 1007 || Number(params.endorsePrice) > 0) && (
                <FormItem
                  {...formItemLayout}
                  label={messages('booking-management.key106', {arg1: currencyCode}/*改签费（{arg1}）*/)}
                >
                  {getFieldDecorator('endorsePrice', {
                    initialValue: isNew ? '' : Number(params.endorsePrice),
                    getValueFromEvent: (e) => this.calcFinalPrice(e, "endorsePrice")
                  })(
                    <InputNumber
                      step="0.01"
                      placeholder={messages('common.please.enter')}
                      disabled={params.status !== 1007}
                    />
                  )}
                </FormItem>
              )
            }
            {isRefund ? refundInput : ""}
            <FormItem {...formItemLayout} label={messages('booking-management.key51'/*最终金额*/)}>
              {getFieldDecorator('finalPrice', {
                initialValue: isNew ? "0.00" : this.filterMoney(params.finalPrice, 2, true)
              })(
                <Input type="text" disabled/>
              )}
            </FormItem>
            {
              isOldFunc && (
                <FormItem
                  {...formItemLayout}
                  label={messages('booking-management.key107', {arg1: currencyCode}/*个人承担费用（{arg1}）*/)}
                >
                  {getFieldDecorator('personalCost', {
                    rules: [{
                      validator: (rule, value, callback) => {
                        const form = this.props.form;
                        if (Number(value) > Number(form.getFieldValue('finalPrice'))) {
                          callback(messages('booking-management.key52'/*个人承担费用无法高于总金额！*/));
                        } else {
                          callback();
                        }
                      }
                    }],
                    initialValue: isNew ? '' : Number(params.personalCost),
                    getValueFromEvent: (e) => this.calcFinalPrice(e, "personalCost")
                  })(
                    <InputNumber step="0.01" placeholder={messages('common.please.enter')}/>
                  )}
                </FormItem>
              )
            }
            <FormItem {...formItemLayout} label={messages('booking-management.key53'/*备注*/)}>
              {getFieldDecorator('remark', {
                rules: [{
                  max: 200,
                  message: messages('booking-management.key54'/*备注字数不能超过200字*/)
                }],
                initialValue: isNew ? '' : params.remark
              })(
                <TextArea placeholder={messages('booking-management.key54'/*备注字数不能超过200字*/)} autosize/>
              )}
            </FormItem>
          </Card>
          <div className="slide-footer">
            {isShowRefundBtn ? refundBtnAffix : ""/*退票 出票后才显示退票按钮*/}
            <Button
              type="primary"
              htmlType="submit"
              loading={loading}
              onClick={(e) => this.updateOrder(e, false)}
              disabled={isDisOnlySave}
              style={isRefund ? {display: "none"} : {}}>{messages('common.save.only')}
            </Button>
            {params.type === 1001 && !isRefund ? issueAndNoticeBtn : ""/*出票并通知乘机人*/}
            {params.type === 1002 && !isRefund && params.status !== 1008 ? issueBtn : ""/*出票*/}
            {params.type === 1001 && isRefund ? refundAndNoticeBtn : ""/*退票并通知*/}
            {params.type === 1002 && isRefund ? refundBtn : ""/*外部参与人且已退票时显示退票*/}
            <Button onClick={this.onCancel}>{messages('common.cancel')}</Button>
          </div>
        </Form>
        <Modal
          title={messages('booking-management.key24'/*退票并通知乘机人*/)}
          visible={refundAndNoticeVisible}
          onOk={this.refundTravelOrder}
          onCancel={() => this.handleCancel("REFUNDANDNOTICE")}
        >
          <p>{`${messages('booking-management.key28'/*乘机人*/)}：${currentPassenger} ${messages('booking-management.key55'/*将在汇联易APP内收到退票信息，请仔细核对信息后确认*/)}`}</p>
        </Modal>
        <Modal
          title={messages('booking-management.key56'/*保存并通知*/)}
          visible={refundVisible}
          onOk={(e) => this.updateOrder(e, true)}
          onCancel={() => this.handleCancel("NOTICE")}
        >
          <p>{`${messages('booking-management.key28'/*乘机人*/)}：${currentPassenger} ${messages('booking-management.key57'/*将在汇联易APP内收到航班信息，请仔细核对信息后确认*/)}`}</p>
        </Modal>
      </div>
    )
  }
}

const WrappedBookingDetailsMaintain = Form.create()(BookingDetailsMaintain);

export default WrappedBookingDetailsMaintain;
